#!/bin/bash
#
# makecopyright - put a copyright info into source files
# Copyright (C) 2009-2011 ZTEX GmbH., http://www.ztex.de
#

# writes the copyright info to stdout
# $1    short description
# $2    begin of comment
# $3    end of comment
msg () {
echo "$2
   $1
   Copyright (C) 2009-2011 ZTEX GmbH.
   http://www.ztex.de

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 3 as
   published by the Free Software Foundation.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, see http://www.gnu.org/licenses/.
$3"
}

readonly=no

# copyright info for single file
# $1    file
# $2    short description
# $3    begin of comment
# $4    end of comment
singlefile () {
#    if [ ! -f "$1" -o -f "$1.tmp" ]; then
    if [ ! -f "$1" ]; then
	return
    fi
    echo "$1"
    if [ "$readonly" = "no" ]; then
	mv "$1" "$1.tmp"
	(
	    msg "$2" "$3" "$4"
	    echo "@@@define[$3][$4
][]" | bmp -mm "@@@" - "$1.tmp"
	) > "$1"
	rm -f "$1.tmp"
    fi
    echo "$1" >> files.tmp
}


# copyright info for single directory
# $1    dir(s)
# $2    description
singledir () {
    if [ ! -d $1 ]; then
	echo "Directory not found: $1"
    fi
    for i in $1/*.pas $1/*.inc; do
	singlefile "$i" "$2" "{*!" "!*}"
    done
    for i in $1/*.c $1/*.h $1/*.java; do
	singlefile "$i" "$2" "/*!" "!*/"
    done
}

rm -f files.tmp

singledir bmp/src "bmp -- babel macro processor"
singledir include "ZTEX Firmware Kit for EZ-USB FX2 Microcontrollers"
singledir java "Firmware / Bitstream loader for the ZTEX EZ-USB FX2 SDK"
singledir java/ztex "Java host software API of ZTEX EZ-USB FX2 SDK"

singledir examples/all/debug "debug -- debug helper example"
singledir examples/all/ucecho "ucecho -- uppercase conversion example for all EZ-USB devices"
singledir examples/all/ucecho/c "UCEcho -- C host software for ucecho examples"

singledir examples/usb-1.0/flashbench "flashbench -- Flash memory benchmark for ZTEX USB Module 1.0"
singledir examples/usb-1.0/flashdemo "flashdemo -- demo for Flash memory access from firmware and host software for ZTEX USB Module 1.0"

singledir examples/usb-fpga-1.2/flashbench "flashbench -- Flash memory benchmark for ZTEX USB-FPGA Module 1.2"
singledir examples/usb-fpga-1.2/flashdemo "flashdemo -- demo for Flash memory access from firmware and host software for ZTEX USB-FPGA Module 1.2"
singledir examples/usb-fpga-1.2/intraffic "intraffic -- example showing how the EZ-USB FIFO interface is used on ZTEX USB-FPGA Module 1.2"
singledir examples/usb-fpga-1.2/lightshow "lightshow -- lightshow on ZTEX USB-FPGA Module 1.2 plus Experimental Board 1.10"
singledir examples/usb-fpga-1.2/standalone "standalone -- standalone firmware that supports FPGA configuration from Flash firmware loading from EEPROM for ZTEX USB-FPGA Module 1.2"
singledir examples/usb-fpga-1.2/ucecho "ucecho -- uppercase conversion example for ZTEX USB-FPGA Module 1.2"

singledir examples/usb-fpga-1.11/flashbench "flashbench -- Flash memory benchmark for ZTEX USB-FPGA Module 1.11"
singledir examples/usb-fpga-1.11/flashdemo "flashdemo -- demo for Flash memory access from firmware and host software for ZTEX USB-FPGA Module 1.11"
singledir examples/usb-fpga-1.11/nvmtest "nvmtest -- ATxmega non volatile memory test on ZTEX USB-FPGA Module 1.11 plus Experimental Board 1.10"
singledir examples/usb-fpga-1.11/standalone "standalone -- standalone firmware that supports FPGA configuration from Flash firmware loading from EEPROM for ZTEX USB-FPGA Module 1.11"
singledir examples/usb-fpga-1.11/1.11a/intraffic "intraffic -- example showing how the EZ-USB FIFO interface is used on ZTEX USB-FPGA Module 1.11a"
singledir examples/usb-fpga-1.11/1.11a/lightshow "lightshow -- lightshow on ZTEX USB-FPGA Module 1.11a plus Experimental Board 1.10"
singledir examples/usb-fpga-1.11/1.11a/memtest "memtest -- DDR SDRAM FIFO for testing memory on ZTEX USB-FPGA Module 1.11a"
singledir examples/usb-fpga-1.11/1.11a/ucecho "ucecho -- uppercase conversion example for ZTEX USB-FPGA Module 1.11a"
singledir examples/usb-fpga-1.11/1.11b/intraffic "intraffic -- example showing how the EZ-USB FIFO interface is used on ZTEX USB-FPGA Module 1.11b"
singledir examples/usb-fpga-1.11/1.11b/lightshow "lightshow -- lightshow on ZTEX USB-FPGA Module 1.11b plus Experimental Board 1.10"
singledir examples/usb-fpga-1.11/1.11b/memtest "memtest -- DDR SDRAM FIFO for testing memory on ZTEX USB-FPGA Module 1.11b"
singledir examples/usb-fpga-1.11/1.11b/ucecho "ucecho -- uppercase conversion example for ZTEX USB-FPGA Module 1.11b"
singledir examples/usb-fpga-1.11/1.11c/intraffic "intraffic -- example showing how the EZ-USB FIFO interface is used on ZTEX USB-FPGA Module 1.11c"
singledir examples/usb-fpga-1.11/1.11c/lightshow "lightshow -- lightshow on ZTEX USB-FPGA Module 1.11c plus Experimental Board 1.10"
singledir examples/usb-fpga-1.11/1.11c/memtest "memtest -- DDR SDRAM FIFO for testing memory on ZTEX USB-FPGA Module 1.11c"
singledir examples/usb-fpga-1.11/1.11c/ucecho "ucecho -- uppercase conversion example for ZTEX USB-FPGA Module 1.11c"

singledir examples/usb-fpga-1.15/flashbench "flashbench -- Flash memory benchmark for ZTEX USB-FPGA Module 1.15"
singledir examples/usb-fpga-1.15/flashdemo "flashdemo -- demo for Flash memory access from firmware and host software for ZTEX USB-FPGA Module 1.15"
singledir examples/usb-fpga-1.15/nvmtest "nvmtest -- ATxmega non volatile memory test on ZTEX USB-FPGA Module 1.15 plus Experimental Board 1.10"
singledir examples/usb-fpga-1.15/standalone "standalone -- standalone firmware that supports FPGA configuration from Flash firmware loading from EEPROM for ZTEX USB-FPGA Module 1.15"
singledir examples/usb-fpga-1.15/1.15b/intraffic "intraffic -- example showing how the EZ-USB FIFO interface is used on ZTEX USB-FPGA Module 1.15b"
singledir examples/usb-fpga-1.15/1.15b/lightshow "lightshow -- lightshow on ZTEX USB-FPGA Module 1.15b plus Experimental Board 1.10"
singledir examples/usb-fpga-1.15/1.15b/memtest "memtest -- DDR2 SDRAM FIFO for testing memory on ZTEX USB-FPGA Module 1.15b"
singledir examples/usb-fpga-1.15/1.15b/mmio "mmio -- Memory mapped I/O example for ZTEX USB-FPGA Module 1.15b"
singledir examples/usb-fpga-1.15/1.15b/ucecho "ucecho -- uppercase conversion example for ZTEX USB-FPGA Module 1.15b"
singledir examples/usb-fpga-1.15/1.15d/intraffic "intraffic -- example showing how the EZ-USB FIFO interface is used on ZTEX USB-FPGA Module 1.15b"
singledir examples/usb-fpga-1.15/1.15d/lightshow "lightshow -- lightshow on ZTEX USB-FPGA Module 1.15b plus Experimental Board 1.10"
singledir examples/usb-fpga-1.15/1.15d/memtest "memtest -- DDR2 SDRAM FIFO for testing memory on ZTEX USB-FPGA Module 1.15b"
singledir examples/usb-fpga-1.15/1.15d/mmio "mmio -- Memory mapped I/O example for ZTEX USB-FPGA Module 1.15b"
singledir examples/usb-fpga-1.15/1.15d/ucecho "ucecho -- uppercase conversion example for ZTEX USB-FPGA Module 1.15b"

singledir examples/usb-xmega-1.0/flashbench "flashbench -- Flash memory benchmark for ZTEX USB-XMEGA Module 1.0"
singledir examples/usb-xmega-1.0/flashdemo "flashdemo -- demo for Flash memory access from firmware and host software for ZTEX USB-XMEGA Module 1.0"
singledir examples/usb-xmega-1.0/nvmtest "nvmtest -- ATxmega non volatile memory test on ZTEX USB-XMEGA Module 1.0"
singledir examples/usb-xmega-1.0/ucecho "ucecho -- uppercase conversion example for ZTEX USB-XMEGA Module 1.0"

#files=`cat files.tmp`
#wc $files
#rm -f files.tmp
